import Sidebar from "./components/Siderbar";
import { useState } from 'react';
import FundamentalChat from "./components/ChatPanel";

export default function App() {
  
  const [selectedStock, setSelectedStock] = useState<any>(null);
  const [selectedDate, setSelectedDate] = useState<any>(null);

  const handleStockSelect = (stock: any) => {
    setSelectedStock(stock);
  };

  const handleSelectedDate = (date: any) => {
    setSelectedDate(date);
  };


  return (
    <div className='flex h-screen'>
      <div className='w-1/3 bg-gray-100 p-4 flex-1 h-full'>
        <Sidebar 
          onStockSelect={handleStockSelect}
          onDateChange={handleSelectedDate}
        />
      </div>

      <div className='w-2/3 bg-gray-100 p-4 h-full'>
        {selectedStock ? (
          <FundamentalChat 
            stockName={selectedStock.shortName} 
            stockCode={selectedStock.code} 
            reportDate={selectedDate} 
          />
        ) : (
          <div className="flex items-center justify-center h-full">
            <h1 className="text-2xl text-gray-500">研究工作台</h1>
          </div>
        )}
      </div>

    </div>
  );
}